#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
void solve()
{
    ll ans=0;
    string s;
    cin >> s;
    for (int i = 1;i<s.size();i++)
    {
        if(s[i]!=s[i-1])
            ans++;
    }
    cout <<( (ans < 5) ? "Yes" : "No") << endl;
}
int main()
{
   int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
